<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:a4j="http://richfaces.org/a4j">
	
<ui:composition template="/layout/template.xhtml">
    
<ui:define name="body">
<a4j:form>
    
<div class="bodyPage container_16">
	
    <div class="grid_16">
    
    	<div class="breadCrumb">
        	<p><span>Você está em:</span> Agenda  >  Consulta</p>
        </div>
    	
        <div>
            <h1>Pesquisa Consultas</h1>
            <div class="grid_9 btns">
                <ul>
                	<li><s:link view="/agenda/CadastroConsulta.xhtml" value="Adicionar Consulta" styleClass="btnAdicionar" action="#{pacienteAction.recuperaTodosPacientes}"/></li>
                </ul>
            </div>
        </div>
        
    	<div class="boxForm">
        	<fieldset>
            	<legend>Dados da Agenda</legend>
                <ul>
                	<li>
                    	<label class="grid_3">Nome do paciente:</label>
                        <span class="grid_12 campo">
                        	<h:inputText value="#{consultaAction.nomePaciente}" styleClass="full"/>
                        </span>
                        
                        <div class="grid_12 campo">
	                        <a4j:commandButton action="#{consultaAction.buscarConsulta}" image="/img/search.png" reRender="listConsultas" style="border:none;">
			        	 		<a4j:status id="loading"  
								            onstart="Richfaces.showModalPanel('panel_loading')"   
								            onstop="Richfaces.hideModalPanel('panel_loading')" >  
					        	</a4j:status>
			        	 	</a4j:commandButton>
                        </div>
                    </li>
                    <!--li>
                    	<label class="grid_3">Data:</label>
                        <div class="grid_12 campo"> 
                        		<rich:calendar id="dataInicio" value="#{consulta.dataConsulta}"></rich:calendar>
                        		<h:inputText id="dataFim" value="#{consulta.dataConsulta}" styleClass="inputP"/>

                        </div>
                    </li-->
                    <li>
                        
                    </li>
                </ul>
            </fieldset>
        </div>
        
        <div class="contentGeral">
            <h2>Resultado da Pesquisa:</h2>
            <div class="grid_9 btns">
        </div>
            
            <div>
            	<table class="full">
         			<rich:dataTable id="listConsultas"
         				value="#{consultaAction.consultas.toArray()}"
         				var="_consulta" onRowMouseOver="this.style.backgroundColor='#9AFF9A'"
                		onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
               			cellpadding="0" cellspacing="0">
         				
         				<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	 <h:outputText value="Data Consulta" />
				  		      </f:facet>
				 				<h:outputText value="#{_consulta.dataConsulta}">
				 					<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
				 				</h:outputText>
				 		</rich:column>
				 		
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Hora Consulta" />
				  		      </f:facet>
				 				<h:outputText value="#{_consulta.dataConsulta}">
				 					<f:convertDateTime type="date" pattern="HH:mm"/>
				 				</h:outputText>
				 		</rich:column>
         			
				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Nome Paciente" />
				  		      </f:facet>
				 				<h:outputText value="#{_consulta.nomePaciente}" />
				 		</rich:column>

				 		<rich:column styleClass="center">
				 			  <f:facet name="header">
					           	  <h:outputText value="Observações" />
				  		      </f:facet>
				 				<h:outputText value="#{_consulta.observacoes}" />
				 		</rich:column>
				 		
				 		<rich:column>
					        	<f:facet name="header">
					                <h:outputText value="Ações" />
					            </f:facet>
					            #{' '}	
					            		<a4j:commandLink ajaxSingle="true" id="addlink"
						                        		  action="#{consultaAction.adicionarAtendimento}">
						                        <f:setPropertyActionListener target="#{consultaAction.consulta}" value="#{_consulta}" />
						                        <h:graphicImage value="../img/adicionar.png" style="border:0"/>
					                    </a4j:commandLink>
					            
					           			 <a4j:commandLink ajaxSingle="true" id="editlink"
						                        		  action="#{consultaAction.populaConsulta}">
						                        <f:setPropertyActionListener target="#{consultaAction.consulta}" value="#{_consulta}" />
						                        <h:graphicImage value="../img/edit_icon.png" style="border:0"/>
					                    </a4j:commandLink>
				   					    
				   					    <a4j:commandLink ajaxSingle="true" id="deletelink"
					                        			action="#{consultaAction.excluiConsulta}" reRender="listConsultas">
			                        			<f:setPropertyActionListener target="#{consultaAction.consulta}" value="#{_consulta}" />
					                        	<h:graphicImage value="../img/close.png" style="border:0" />
					                    </a4j:commandLink>
					        </rich:column>
				     </rich:dataTable>
                </table>
            </div>
            
        </div>
        
    </div>
    
</div><!-- #bodyPage -->

	<rich:modalPanel id="panel_loading" autosized="true">
			<h:graphicImage url="/img/loading.gif" style="border:0px; vertical-align: middle;" />
				<rich:spacer width="20" /><br/>
				<h:outputText value="Carregando... Aguarde!" />
	</rich:modalPanel>
	
	<rich:modalPanel id="editPanel" autosized="true" width="450">
	
		<f:facet name="header">
            <h:outputText value="Editar Consulta" />
        </f:facet>
        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage value="../img/close.png" id="hidelink"
                    styleClass="hidelink" />
                <rich:componentControl for="editPanel" attachTo="hidelink"
                    operation="hide" event="onclick" />
            </h:panelGroup>
        </f:facet>
        <h:form>
        </h:form>
        
	</rich:modalPanel>
	
	<rich:modalPanel id="deletePanel" autosized="true" width="200">
        <f:facet name="header">
            <h:outputText value="Deseja deletar esse registro?"
                style="padding-right:15px;" />
        </f:facet>
        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage value="../img/close.png"
                    styleClass="hidelink" id="hidelink2" />
                <rich:componentControl for="deletePanel" attachTo="hidelink2"
                    operation="hide" event="onclick" />
            </h:panelGroup>
        </f:facet>
        <h:form>
            <table width="100%">
                <tbody>
                    <tr>
                        <td align="center" width="50%"><a4j:commandButton value="Yes"
                            ajaxSingle="true"
                            oncomplete="#{rich:component('deletePanel')}.hide();"
                            reRender="table" /></td>
                        <td align="center" width="50%"><a4j:commandButton
                            value="Cancel"
                            onclick="#{rich:component('deletePanel')}.hide();return false;" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </h:form>
    </rich:modalPanel>
    
</a4j:form>
</ui:define>    
</ui:composition>    
</html>